<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>demo</title></title>
</head>
<body>
  <div id="root"></div>
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  <script src="https://unpkg.com/prop-types@15.6/prop-types.js"></script>
  <script type="text/babel">

    class Form extends React.Component{

      username = React.createRef()
      password = React.createRef()

      handleSubmit = (event)=>{
        event.preventDefault()
        const username = this.username.current.value
        const password = this.password.current.value
        console.log(this)
        console.log(username,password)

      }

      render(){
        return (
          <form onSubmit={this.handleSubmit}>
            <input name="username" ref={this.username} />
            <input name="password" ref={this.password} />
            <button>提交</button>
          </form>
        )
      }
    }

    ReactDOM.render(<Form />,document.getElementById("root"))
  </script>
</body>
</html>